<template>
    <div class="age">
        <div class="top">
            <div class="title">年龄比例</div>
            <img src="../images/dataScreen-title.png" alt="" srcset="">
        </div>
        <div class="charts" ref="charts"></div>
    </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import * as echarts from 'echarts';
const charts = ref()
onMounted(() => {
    const myChart = echarts.init(charts.value);
    myChart.setOption({
        tooltip: {
            trigger: 'item'
        },
        legend: {
            top: '15%',
            right: 60,
            orient: 'vertical',
            textStyle: {
                color: 'white'
            }
        },
        series: [
            {
                name: 'Access From',
                type: 'pie',
                radius: ['50%', '80%'],
                avoidLabelOverlap: false,
                itemStyle: {
                    borderRadius: 8
                },
                label: {
                    show: true,
                    position: 'inside'
                },
                emphasis: {
                    label: {
                        show: true,
                        fontSize: 30,
                        fontWeight: 'bold'
                    }
                },
                labelLine: {
                    show: false
                },
                data: [
                    { value: 1048, name: '军事' },
                    { value: 735, name: '新闻' },
                    { value: 580, name: '娱乐' },
                    { value: 484, name: '财经' },
                    { value: 300, name: '直播' }
                ],
                grid: {
                    top: 20,
                    left: 0,
                    right: 100,
                    bottom: 0
                }
            }
        ]
    })
})
</script>

<style lang="scss" scoped>
.age {
    width: 100%;
    height: 235px;
    background: url(../images/dataScreen-main-lb.png) no-repeat;
    background-size: cover;

    .top {
        .title {
            font-size: 20px;
            color: white;

        }
    }

    .charts {
        width: 100%;
        height: calc(100% - 50px);
    }
}
</style>